.class public Fibo
.super java/lang/Object

.method public <init>()V
  aload_0
  invokenonvirtual java/lang/Object/<init>()V
  return
.end method

.method public static main([Ljava/lang/String;)V
  .limit stack 10
  .limit locals 5
  
  ; Load the value for n
  ldc 10
  istore 4

  ; Check if n <= 1
  iload 4
  ldc -1
  iadd
  ifle print

  ; n >= 2, do loop
  ldc 1       ; f0 = 1
  istore 0
  ldc 1       ; f1 = 1
  istore 1

  iload 4     ; n - 1
  ldc -1
  iadd
  istore 3    ; i = n - 2

  forloop:
    iload 0     ; f = f0 + f1
    iload 1
    iadd
    istore 2

    iload 1     ; f0 = f1
    istore 0

    iload 2     ; f1 = f
    istore 1

    iinc 3 -1
    iload 3
    ifne forloop

  iload 2 ; n = f
  istore 4

  ; Print the value of n
  print:
    iload 4
    invokestatic Helper/p(I)V
  return

.end method
